<template>
	<div class="banner-edit-box" :style="`width: ${screenWidth}px;height: ${screenHeight}px`" v-show="coverShow">
		<div ref="editCover" class="edit-cover" :class="[coverShow ? 'edit-cover-show' : 'edit-cover-hide']"></div>
		<div class="edit-content" ref="editContent" id="edit-model-box">
			<div class="edit-title-box" :class="menuShow ? 'edit-title-box-active' : ''">
				<div class="edit-title">{{title}}</div>
				<span class="edit-close" @click="hideCover">×</span>
			</div>
			<div class="slot-box" :class="menuShow ? 'slot-box-active' : ''">
				<slot name="main"></slot>
			</div>
			<div class="edit-slide-menu" ref="slideMenu"
				 :class="menuShow ? 'edit-slide-menu-active' : ''"
			>
				<div class="slide-title-box">
					<div class="edit-title">商品查找</div>
					<span class="edit-close" @click="hideMenu">×</span>
				</div>
				<div class="slide-slot-box">
					<slot name="slide"></slot>	
				</div>
			</div>
			<!-- :class="menuShow ? 'edit-slide-menu-active' : ''"  -->
		</div>
	</div>
</template>

<script>
export default {
		props: {
			text: {
				type: String,
				default: "保存"
			},
			title: {
				type: String,
				default: "Banner位配置"
			},
			closeCallback: {
				type: Function,
				default: () => {}
			}
		},
		data () {
			return {
				coverShow: false,
				menuShow: false
			}
		},
		computed: {
			screenWidth() {
				return window.screen.width;
			},
			screenHeight() {
				return window.innerHeight;
			}
		},
		components: {},
		created () {
			console.log(this.$store);
		},
		mounted () {

		},
		methods: {
			//显示模态框
			showCover() {
				this.coverShow = true;
				setTimeout(() => {
					this.$refs.editCover.style.opacity = "0.4";
					this.$refs.editContent.style.transform = "translateY(30px)"
				}, 0);

			},
			//隐藏模态框
			hideCover() {
				setTimeout(() => {
					this.$refs.editCover.style.opacity = "0";
					this.$refs.editContent.style.transform = "translateY(-300px)"
				}, 0);
				setTimeout(() => {
					this.closeCallback();
					this.coverShow = false;
					this.menuShow = false;
				}, 200);
			},
			//显示侧滑栏
			showSlideMenu() {
				this.menuShow = true;
			},
			//隐藏侧滑栏
			hideMenu() {
				this.menuShow = false;
			}
		}
	}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
	.banner-edit-box {
		position: fixed;
		left: 0;
		top: 0;
		z-index: 11;
	}

	.edit-cover {
		position: absolute;
		left: 0;
		top: 0;
		background: #000;
		width: 100%;
		height: 100%;
		opacity: 0;
		transition: opacity 0.3s;

	}

	.edit-cover-show {
	}

	.edit-cover-hide {
	}

	.edit-content {
		background: #fff;
		width: 550px;
		position: absolute;
		left: -220px;
		right: 0;
		border-radius: 3px;
		margin: auto;
		transform: translateY(-300px);
		transition: transform 0.3s ease-out;
		/* max-height: 90vh;
		overflow: auto; */
	}
	.edit-content-active {
	}
	.edit-content-show {
	}

	.edit-title-box, .slide-title-box {
		border-top-left-radius: 3px;
		border-top-right-radius: 3px;
		background: #fff;
		position: relative;
		z-index: 1;
		display: flex;
		box-sizing: border-box;
		padding: 15px;
		width: 100%;
		height: 60px;
		justify-content: space-between;
		align-items: center;
		border-bottom: 1px solid #ddd;
	}
	.slide-title-box {
		z-index: unset;
	}
	.edit-title-box-active {
		border-top-right-radius: 0;
	}

	.edit-close {
		font-size: 20px;
		font-weight: bold;
		color: #ddd;
		cursor: pointer;
	}

	.edit-close:hover {
		color: #444;
	}

	.slot-box, .slide-slot-box {
		/* background: #eef3f9; */
		background: #fff;
		border-bottom-left-radius: 3px;
		border-bottom-right-radius: 3px;
		position: relative;
		z-index: 1;
		padding: 20px;
		box-sizing: border-box;
	}
	.slide-slot-box {
		z-index: unset;
	}
	.slot-box-active {
		border-bottom-right-radius: 0;
	}

	.slot-banner .eidt-slot-title {
		width: 100px;
		text-align: left;
	}

	.slot-box input {
		border: 1px solid #ddd;
		padding: 5px 5px;
		width: 50%;
		height: unset;

	}

	.slot-box input[type=text] {
		/* width: 50%; */

	}
	/* 侧滑栏的样式 */
	.edit-slide-menu {
		width: 300px;
		overflow: hidden;
		height: 100%;
		position: absolute;
		right: 0;
		top: 0;
		/* background: #b5d1f5;  */
		background: #fff;
		border-top-right-radius: 3px;
		border-bottom-right-radius: 3px;
		 border-left: 1px solid #ddd; 
		transition: transform 0.5s;

	}
	.edit-slide-menu-active {
		transform: translateX(100%);
	}
</style>
